<?php

function reequipment_user_report_time()
{  
    if (!xarVarFetch('phase', 'enum:downtime:manhours', $phase, 'item_cost', XARVAR_NOT_REQUIRED, XARVAR_PREP_FOR_DISPLAY)) return;
    
    if (!xarSecurityCheck('EditEquipment', 1)) return;
    $data = array();
    xarTplSetPageTitle(xarML('Item Cost Report'));
     // Get company_id
    if (!xarVarFetch('company_id', 'int:1:', $company_id, '', XARVAR_NOT_REQUIRED)) return; 
	if (!xarModAPIFunc('reequipment', 'user', 'getcompanyid', array('company_id_from_url' => $company_id))) return;
	$company_id = xarSessionGetVar('company_id');
	
	switch(strtolower($phase)) {
		case 'downtime':
			$data['maintenance'] = xarModAPIFunc('reequipment', 'user', 'getmaintenance', array('company_id' => $company_id, 'complete' => true));
			// return var_export($data['items']);
			$data['group'] = xarModAPIFunc('reequipment', 'user', 'groupdowntime', array('company_id' => $company_id));
			// return var_export($data['shipping']);
			$data['report_title'] = xarML('Downtime Report for');
			$data['label'] = xarML('Down Time');
		break;
		
		case 'manhours':
		
			$data['maintenance'] = xarModAPIFunc('reequipment', 'user', 'getmaintenance', array('company_id' => $company_id, 'complete' => true));
			// return var_export($data['items']);
			$data['group'] = xarModAPIFunc('reequipment', 'user', 'groupmanhours', array('company_id' => $company_id));
			// return var_export($data['shipping']);
			$data['report_title'] = xarML('Man Hour Report for');
			$data['label'] = xarML('Man Hours');
		
	}
	
    // Company Name
	$companies = xarModAPIFunc('reequipment', 'user', 'getrel', array('company_id' => $company_id));
	foreach($companies as $var){
		$data['company_name'] = $var['company_name'];
	}
    return $data;
}

?>